package cn.wwcyc.utils;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class JsoupUtil {
    public static void main(String[] args) throws IOException {
        String url = "http://10.213.14.170:8080/zbpcs/scxxh/zbKhzb_cyc.action";
        String data= "dwdm=31300000&rq=2023-07-31";
        Document document = Jsoup.connect(url)
                .requestBody(data)
                .header("Content-Type", "application/x-www-form-urlencoded")
                .ignoreContentType(true)
                .timeout(120000)
                .post();


////        con.
//        Document document = Jsoup.parse(new URL(url), 5000);
        Element table = document.getElementsByTag("table").get(0);
        Elements trs = table.getElementsByTag("tr");
        Element wwcyctr = null;
        for(Element tr: trs){
//            System.out.println(tr.getElementsByTag("a").text());
            if(tr.getElementsByTag("a").text().equals("文卫采油厂")){
                wwcyctr = tr;
                break;
            }
        }
//        System.out.println(wwcyctr);
        String wwcyczb = wwcyctr.getElementsByTag("td").get(1).text();
        System.out.println(wwcyczb);
//        System.out.println(ele);
    }
}
